<?php

namespace app\ticket\validate;

use think\Validate;

class Ticket extends Validate {
    protected $rule = [

        'product_id'    =>'require',
        'category_id'   =>'require',
        'user_id'       => 'require',
        'title'         => 'require|max:20',
        'description'   => 'require',
        'phone'         => 'require|number|length:11',
        'contact_time'  => 'require|in:1,0,-1',
        'cover_ids'       => 'require|gt:0',

        'staff_id'      => 'require',
        'num_score'     => 'require|number',
        'is_finish'     => 'require',
        'feed_back'     => 'require',
    ];

    protected $scene = [
        'add' => ['user_id','product_id','category_id','title','description','phone','contact_time',],
        'update' => ['staff_id',],
        'finish' => ['num_score','is_finish','feed_back']
    ];

    protected $message = [
        'product_id.require'         => '无效的产品',
        'category_id.require'        => '无效的问题类型',
        'user_id.require'            => '无效的用户',
        'title.require'              => '问题标题不能为空',
        'title.max'                  => '问题标题不能超过20字符',
        'description.require'        => '问题描述不能为空',
        'phone.require'              => '联系人电话不能为空',
        'phone.number'               => '联系人电话格式有误',
        'phone.length'               => '联系人电话格式有误',
        'contact_time.require'       => '联系时机不能不选',
        'contact_time.in'            => '联系时机有误',
        'file_id.gt'                  => '附件不能为空',
        'staff_id.require'           => '员工不能为空',
        'num_score.require'          => '分数不能为空',
        'num_score.number'           => '分数只能为数字',
        'is_finish.require'          => '是否完成不能为空',
        'feed_back.require'          => '反馈不能为空',
    ];
}